<!--
 * @Description: 发放梯度奖励确认弹窗
 * @Author: liyujie
 * @Date: 2021/05/17
 * @Last Modified by: liyujie
 * @Last Modified time: 2021/05/17
-->
<template>
    <section class="wrapper">
        <el-dialog
            title="发放奖励"
            width="800px"
            :visible.sync="visible"
            @close="beforeClose"
        >
            <div class="base-info">
                <div class="base-info-title">
                    奖励发放对象
                </div>
                <div class="base-info-form">
                    <div class="base-info-form-item">
                        <div class="base-info-form-item__label">
                            用户昵称：
                        </div>
                        <div class="base-info-form-item__content">
                            {{ formData.true_name }}
                        </div>
                    </div>
                    <div class="base-info-form-item">
                        <div class="base-info-form-item__label">
                            联系电话：
                        </div>
                        <div class="base-info-form-item__content">
                            {{ formData.phone }}
                        </div>
                    </div>
                    <div class="base-info-form-item">
                        <div class="base-info-form-item__label">
                            已完成数量：
                        </div>
                        <div class="base-info-form-item__content">
                            --
                        </div>
                    </div>
                </div>
            </div>
            <div class="content-table">
                <div class="table-title">
                    选择发放奖励的梯度
                </div>
                <el-table
                    v-if="formData.award_config_data"
                    :data="formData.award_config_data.award_item_list"
                    max-height="240"
                    @row-click="handleRadioChange"
                >
                    <el-table-column
                        width="50"
                        align="center"
                    >
                        <template slot-scope="scope">
                            <el-radio
                                v-model="selectId"
                                :label="scope.row.id"
                                @change="handleRadioChange(scope.row)"
                            >&nbsp;</el-radio>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="梯度等级"
                        align="center"
                    >
                        <template slot-scope="scope">
                            梯度{{ scope.$index + 1 }}
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="要求数量"
                        prop="requireSubmitCount"
                        align="center"
                    />
                    <el-table-column
                        label="完成数量"
                        prop="has_award_num"
                        align="center"
                    />
                    <el-table-column
                        label="奖励类型"
                        align="center"
                    >
                        <template slot-scope="scope">
                            {{ scope.row.type === 1 ? '现金奖励' : '0元购学生券' }}
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="奖励金额/数量"
                        align="center"
                        width="130"
                    >
                        <template slot-scope="scope">
                            {{ scope.row.total_num }}{{ scope.row.type === 1 ? '元' : '张' }}
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="用户端显示金额"
                        align="center"
                        width="130"
                    >
                        <template slot-scope="scope">
                            <div v-if="scope.row.type === 1">{{ scope.row.num }}元</div>
                            <div v-else>--</div>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <div slot="footer">
                <el-button
                    size="medium"
                    style="width: 120px; margin-right: 60px;"
                    @click="visible = false"
                >
                    取消
                </el-button>
                <el-button
                    size="medium"
                    style="width: 120px"
                    type="primary"
                    @click="handleConfirm"
                >
                    确定
                </el-button>
            </div>
        </el-dialog>
    </section>
</template>

<script>
export default {
    name: "GrantGradientAwardDialog",
    data() {
        return {
            visible: false,
            selectId: '',
            formData: {},
        };
    },
    methods: {
        show(data) {
            this.formData = data;
            this.visible = true;
        },

        close() {
            this.visible = false;
        },

        beforeClose() {
            this.selectId = '';
        },

        /**
         * 点击radio
         * @param row
         */
        handleRadioChange(row) {
            this.selectId = row.id;
        },

        /**
         * 确定提交
         */
        handleConfirm() {
            if(!this.selectId) {
                this.$message.warning('请选择奖励梯度');
                return;
            }
            this.$emit('confirm', this.selectId);
            this.close();
        }
    }
};
</script>

<style scoped lang="less">
.wrapper {
    .base-info {
        border-bottom: 1px solid #EBEEF5;
        margin: 0 48px;

        &-title {
            font-size: 14px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #333333;
        }

        &-form {
            display: flex;

            &-item {
                display: flex;
                font-size: 14px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                margin: 24px 32px 24px 0;

                &__label {
                    color: #888888;
                }

                &__content {
                    color: #333333;
                }
            }
        }
    }

    .content-table {
        margin: 24px 48px 0;

        .table-title {
            font-size: 14px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #333333;
            margin-bottom: 12px;
        }

    }

    /deep/ .el-dialog__header {
        padding-top: 10px;
        box-shadow: 0 1px 0 0 rgba(233, 233, 233, 1);
        display: flex;
        align-items: center;
        background: #FAFAFA;
        border-radius: 4px 4px 0 0;

        .el-dialog__title {
            font-weight: 500;
            color: #333;
            font-size: 14px;
        }

        .el-icon-close:before {
            color: rgb(194, 194, 194);
            font-size: 17px;
            font-weight: bold;
        }

        .el-dialog__headerbtn {
            top: 14px;
        }
    }

    /deep/ .el-table__fixed-right {
        right: 6px !important;
    }

    /deep/ .el-dialog__footer {
        text-align: center;
        padding-bottom: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /deep/ .el-textarea__inner {
        resize: none;
    }
}
</style>
